<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>jQuery响应式图片无缝轮播插件|DEMO_jQuery之家-自由分享jQuery、html5、css3的插件库</title>
	<link rel="stylesheet" type="text/css" href="css/normalize.css" />
	<link rel="stylesheet" type="text/css" href="css/htmleaf-demo.css">
	<style type="text/css">
		   *{
	            margin: 0;
	            padding: 0;
	            list-style-type: none;
	        }
	        .banner{
	            width: 100%;
	            position: relative;
	            overflow: hidden;
	        }
	        .banner ul{
	            position: absolute;
	        }
	        .banner ul li{
	            width: 100%;
	            height: 560px;
	            float: left;
	            background:  no-repeat center center;
	        }
	        .banner ol{
	            height: 20px;
	            background: rgba(0,0,0,0.5);
	            position: absolute;
	            left:50%;
	            bottom: 30px;
	            padding: 0 10px;
	            border-radius: 10px;
	        }
	        .banner ol li{
	            width: 10px;
	            height: 10px;
	            float: left;
	            margin: 5px 5px;
	            background: rgba(255,255,255,0.5);
	            border-radius: 50%;
	            cursor: pointer;
	        }
	        .banner ol .current{
	            background: rgba(255,255,255,1);
	        }
	        .banner i{
	            width: 58px;
	            height: 120px;
	            position: absolute;
	            top: 50%;
	            margin-top: -60px;
	            cursor: pointer;
	            border-radius: 5px;
	            display: none;
	        }
	        .banner .left{
	            left: 60px;
	            background: url('img/left_right.png') no-repeat 0 0px;
	        }
	        .banner .right{
	            right: 60px;
	            background: url('img/left_right.png') no-repeat 0px -120px;
	        }
	        .banner .left:hover , .banner .right:hover{
	            background-color: rgba(0, 0, 0, 0.31);
	        }
	</style>
</head>
<body>
		<div class="banner">
		        <ul>
		        </ul>
		        <ol>
		        </ol>
		        <i class="left"></i><i class="right"></i>
		    </div>
	
	<script src="http://cdn.bootcss.com/jquery/1.11.0/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript">
		$(function(){ 
            var images_height = '560px';
            var images_url = [
                'img/1.jpg',
                'img/2.jpg',
                'img/3.jpg'
            ];
            var images_count = images_url.length;

            for(var j=0;j<images_count+1;j++){
                $('.banner ul').append('<li></li>')
            }
            for(var j=0;j<images_count;j++){
                if(j==0){
                    $('.banner ol').append('<li class="current"></li>')
                }else{
                    $('.banner ol').append('<li></li>')
                }
            }

            $('.banner ul li').css('background-image','url('+images_url[0]+')');
            $.each(images_url,function(key,value){
                $('.banner ul li').eq(key).css('background-image','url('+value+')');
            });

            $('.banner').css('height',images_height);

            $('.banner ul').css('width',(images_count+1)*100+'%');

            $('.banner ol').css('width',images_count*20+'px');
            $('.banner ol').css('margin-left',-images_count*20*0.5-10+'px');


            var num = 0;
            var window_width = $(window).width();
            $(window).resize(function(){
                window_width = $(window).width();
                $('.banner ul li').css({width:window_width});
                clearInterval(timer);
                nextPlay();
                timer = setInterval(nextPlay,2000);
            });

            $('.banner ul li').width(window_width);
  
            $('.banner ol li').mouseover(function(){
                $(this).addClass('current').siblings().removeClass('current');

                var i = $(this).index();
        
                $('.banner ul').stop().animate({left:-i*window_width},500);
                num = i;
            });
            
            var timer = null;
            function prevPlay(){
                num--;
                if(num<0){
                    
                    $('.banner ul').css({left:-window_width*images_count}).stop().animate({left:-window_width*(images_count-1)},500);
                    num=images_count-1;
                }else{
               
                    $('.banner ul').stop().animate({left:-num*window_width},500);
                }
                if(num==images_count-1){
                    $('.banner ol li').eq(images_count-1).addClass('current').siblings().removeClass('current');
                }else{
                    $('.banner ol li').eq(num).addClass('current').siblings().removeClass('current');

                }
            }
            function nextPlay(){
                num++;
                if(num>images_count){
                   
                    $('.banner ul').css({left:0}).stop().animate({left:-window_width},500);
                   
                    num=1;
                }else{
                   
                    $('.banner ul').stop().animate({left:-num*window_width},500);
                }
                if(num==images_count){
                    $('.banner ol li').eq(0).addClass('current').siblings().removeClass('current');
                }else{
                    $('.banner ol li').eq(num).addClass('current').siblings().removeClass('current');

                }
            }
            timer = setInterval(nextPlay,2000);
    
            $('.banner').mouseenter(function(){
                clearInterval(timer);
          
                $('.banner i').fadeIn();
            }).mouseleave(function(){
                timer = setInterval(nextPlay,2000);
              
                $('.banner i').fadeOut();
            });
  
            $('.banner .right').click(function(){
                nextPlay();
            });
       
            $('.banner .left').click(function(){
                prevPlay();
            });
        });
	</script>
</body>
</html>